home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-12 | 2.6 KB | 122 lines | [TEXT/MMCC] |
- // graphics.c
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <QDOffscreen.h>
-
- #include "mytypes.h"
- #include "error.h"
-
- #include "graphutil.h"
- #include "fastmap.h"
- #include "graphics.h"
- #include "window.h"
- #include "blit.h"
-
- enum {
- kBaseFastmapID = 128,
- kBaseGWorldID = 500
- };
-
- frameData frameCounts[kmaxpix] = // frames, masked
- {
- {6, true},
- {6, true},
- {6, true},
- {6, true},
- {6, true},
- {6, true},
- {6, true},
- {6, true}
- };
-
- RGBColor rgbBlack = {0,0,0};
- RGBColor bugcol = {0xC000,0xC000,0xC000};
-
- Rect blockrect[kmaxpix], blockrectworld[kmaxgworlds];
- Rect boffrect;
- Fastmap *bpix[kmaxpix][kmaxframes];
- GWorldPtr bworld[kmaxgworlds];
- GWorldPtr bmask[kmaxgworlds];
- GWorldPtr boff;
- GDHandle maindev;
-
-
- static void
- alignseedz(void)
- {
- long *seedptr, *srcseed;
-
- if (gGameWindDepth != 8)
- return;
-
- srcseed = &((**(**(**maindev).gdPMap).pmTable).ctSeed);
- seedptr = &((**(**boff->portPixMap).pmTable).ctSeed);
-
- // if (pgGameWindDepth == 8)
- // if (*srcseed != *seedptr) {
-
- *seedptr = *srcseed; // for fast quickdraw
- seedptr = &((**(**boff->portPixMap).pmTable).ctSeed);
- *seedptr = *srcseed; // for fast quickdraw
- }
-
- void LoadAllGraphics(void)
- {
- int i, j;
- CTabHandle dacolors;
- GDHandle SaveGD;
- CGrafPtr SavePort;
-
- GetGWorld(&SavePort, &SaveGD);
-
- qd.randSeed = TickCount();
- // just in case . . .
- for (i=0;i<kmaxgworlds;i++)
- bworld[i] = 0;
- for (i=0;i<kmaxpix;i++)
- for (j=0;j<kmaxframes;j++)
- bpix[i][j] = 0;
-
- // if (gGameWindDepth == 8)
- // dacolors = (CTabHandle) colorTab;
- // else
- dacolors = 0;
-
- GetPixFromResources(kBaseGWorldID, kmaxgworlds, blockrectworld, bworld, bmask, dacolors);
- verify(bworld[0]);
-
- SetRect(&boffrect, 0, 0, kBoardSize, kBoardSize);
- makegworld(&boff, &boffrect, 8, dacolors);
- SetGWorld(boff, nil);
- TextSize(10);
- TextFont(geneva);
- // TextMode(srcBic);
-
- LoadFastmaps(kBaseFastmapID, kmaxpix, frameCounts, blockrect, (Fastmap **) bpix, kmaxframes);
-
- // back2boff();
-
- // if necessary we convert all pixmaps into the depth of the gamewindow
- if (gGameWindDepth != 8)
- for (i=0;i<kmaxgworlds;i++) {
- GWorldPtr tempgw;
-
- if (!bworld[i])
- continue;
- makegworld(&tempgw, &blockrectworld[i], gGameWindDepth, 0);
- if (!tempgw) {
- DebugStr("\pFailure to load graphics.");
- continue;
- }
- SetGWorld(tempgw, nil);
- CopyBits ((BitMap *) *(bworld[i]->portPixMap), (BitMap *) *(tempgw->portPixMap),
- &blockrectworld[i], &blockrectworld[i], srcCopy, nil);
- UnlockPixels(bworld[i]->portPixMap);
- DisposeGWorld(bworld[i]);
- bworld[i] = tempgw;
- tempgw = 0;
- }
-
- SetGWorld(SavePort, SaveGD); // restore original world (save the Earth)
- }